package com.apes.scm.masterdata.dcDeliveryArea.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.frame.model.Organization;
import com.apes.scm.masterdata.stock.model.Location;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;


@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = DcDeliveryArea.CONST_TABLE_NAME)
public class DcDeliveryArea extends Model {
    public static final String CONST_TABLE_NAME = "mas_dc_delivery_area";

    @Id
    @Column(name="id", length = 30)
    @ApesGenerator(code=CONST_TABLE_NAME, name = "DC编码")
    @Comment("唯一编码")
    private String id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="organization_id", referencedColumnName = "id")
    @Comment("采购组织")
    private Organization organizationId; // 采购组织

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="parent_warehouse_id", referencedColumnName = "id")
    @Comment("父仓库库区")
    private Location prentLocationId; // 父仓库库区

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name="sub_warehouse_id", referencedColumnName = "id")
    @Comment("子仓库")
    private Location subLocationId;    // 子仓库

    @Column(name = "ZDPHBJ", columnDefinition = "number(1,0) default 1")
    @Comment("自动配货标记")
    private boolean ZDPHBJ;

}
